<template>
    <div id="slide">
        <slide :data="data"></slide>

        <transition :name="transition_name">
            <router-view class="children" />
        </transition>
    </div>
</template>

<script>
    import slide from "../../../../module/slide/Slide";
    import share from "../../../../util/share";
    export default {
        name: "me-slide",
        data(){
            return {
                transition_name:"",
                red_id:0,  //红包的id
                data:[]  //红包列表
            }
        },
        components:{
            slide
        },
        beforeRouteUpdate(to, from, next){
            this.transition_name = to.path.split('/').length < from.path.split('/').length ? "animated child-animated slideOutRight delay-2s" : "animated child-animated slideInRight delay-2s";
            setTimeout(()=>{
                next();
            },10);
        },
        created(){
            let {red_id} = this.$route.params;
            this.red_id = red_id;
            this.getRedDetail();
        },
        methods:{
            /**
             * 获取当前活动的详情
             */
            getRedDetail(){
                this.$url('redDetail/easyFind',{
                    red_id:this.red_id,
                    return:['red_type']
                })
                    .then((res)=>{
                        if(res.data.status === 'success'){
                            this.data = [{id:this.red_id,red_type:res.data.data.red_type}];
                            if(this.$wx) share(this.$route.name,this.red_id);
                        }
                    });
            }
        }
    }
</script>

<style scoped lang="less" src="./slide.less"></style>
